#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
const double esp = 1e-7;
struct car{
    double d,v,a;
    double pos;
    double l,r;
    bool zk,yk;
    bool sf;
}a[maxn];
int n,m;
double L,V;
double p[maxn];
double pos[maxn];
double l[maxn],r[maxn];
struct line{
    int l,r;
}g[maxn];
vector<int>mp[maxn];
int f[1000005];
void solve(){
    memset(a,0,sizeof(a));
    cin>>n>>m>>L>>V;
    for(int i = 1;i<=n;i++)mp[i].clear();
    for(int i = 1;i<=n;i++){
        cin>>a[i].d>>a[i].v>>a[i].a;
        if(a[i].a == 0)a[i].pos = -1;
        else a[i].pos = max((V*V-a[i].v*a[i].v)/(2*a[i].a),(double)0)+a[i].d;
        if(a[i].a == 0){
            if(a[i].v>V)a[i].l = a[i].d,a[i].r = L;
            else a[i].sf = 1;
        }else if(a[i].a>0){
            if(a[i].pos>=L)a[i].sf = 1;
            else a[i].l = a[i].pos,a[i].zk = 1,a[i].r = L;
        }else{
            if(a[i].v<=V)a[i].sf = 1;
            else a[i].l = a[i].d,a[i].r = min(a[i].pos,L),a[i].yk = 1;
        }
    }
    int tot = 0,ans1 = 0;
    for(int i = 1;i<=n;i++)if(!a[i].sf)l[++tot] = a[i].l,r[tot] = a[i].r;
    sort(l+1,l+1+tot); sort(r+1,r+1+tot);
    int lcnt = 1,rcnt = 1,now = 0;
    for(int i = 1;i<=m;i++)cin>>p[i];
    for(int i = 1;i<=n;i++){
        if(a[i].sf)continue;
        int ppl,ppr;
        if(a[i].zk)ppl = upper_bound(p+1,p+1+m,a[i].l)-p;
        else ppl = lower_bound(p+1,p+1+m,a[i].l)-p;
        if(a[i].yk)ppr = lower_bound(p+1,p+1+m,a[i].r)-p-1;
        else ppr = lower_bound(p+1,p+1+m,a[i].r)-p;
        if(ppr>m)ppr = m;
        if(ppl<0)ppl = 0;
        if(ppl>ppr)continue;
        g[++ans1].l = ppl;
        g[ans1].r = ppr;
    }
    for(int i = 1;i<=ans1;i++){
        int ppr = g[i].r,ppl = g[i].l;
        mp[ppr].push_back(i);
    }
    cout<<ans1<<' ';
    for(int i = 1;i<=m;i++){
        if(mp[i].size()!=0){
            for(int j = 0;j<mp[i].size();j++){
                int id = mp[i][j];
                //cout<<g[id].l<<' '<<g[id].r<<' '<<f[i]<<' '<<f[g[id].l-1]<<'\n';
                if(j>0)f[i] = max(f[i],f[g[id].l-1]+1);
                else f[i] = max(f[i-1],f[g[id].l-1]+1);
            }
        }else f[i] = f[i-1];
    }
    cout<<m-f[m]<<'\n';
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--)solve();
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15


*/
